home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn Microsoft Visual Basic 6.0 Now
/
Learn Microsoft Visual Basic 6.0 Now (Microsoft Press)(X03-58607)(1998).ISO
/
media
/
chap08
/
b08d010.cc2
< prev
next >
Wrap
Text File
|
1998-06-07
|
3KB
|
73 lines
0, Okay, in this demo I'd like to soup up
2, the burn barrel drag-and-drop program by
5, adding an animation effect. When the
7, match icon goes into the burn barrel, and
10, the flame appears, I'd like to create a
12, smoke cloud that drifts gently off the
13, screen. The secret to doing this will be
17, to create a timer object that moves the
19, cloud icon off the screen in short and
21, smooth increments. First, I'll click the
25, Picture Box control in the toolbox and
28, I'll draw a small rectangle above the
30, empty burn barrel on the form. Then, I'll
38, set the following properties for the
39, picture box. I'll change the Appearance
42, property to Flat. I'll change the BackColor
47, property to that nice warm gray, and I'll
56, remove the border by changing the
59, BorderStyle property to None. And I'll open
64, up a nice picture by setting the Picture
67, property to a cloud icon. And finally,
78, I'll make this invisible by setting the
81, Visible property to False. When my
84, animation runs, I'll make that visible with
87, program code. Now, I'll click the Timer
91, control in the Visual Basic toolbox and
93, add a timer object to my form for the
95, animation. And I'll set the following properties for
99, my timer. First, I'll enable it by setting
103, its Enable property to True, and I'll
107, set the interval, or tick rate, to 65
110, milliseconds. Now, I'll close the
114, Properties window and double-click the empty burn
118, barrel to open its DragDrop event
122, procedure. And I'll add two lines. The first,
129, Picture1.Visible = True, will display
138, my cloud. And the second, Timer1.Enabled
146, = True, will start the animation going
150, that is keyed off of the timer object.
154, Now, I'll open the drop-down list box and
158, select the timer object and add the
163, program code that goes into the Timer event
166, procedure. As long as the timer is
172, enabled, this If...Then decision structure is
176, executed every sixty-five milliseconds.
179, The first line in the procedure checks
181, whether the smoke cloud has reached the
182, top of the form. If it hasn't, if its
185, Top property is still positive, the
188, procedure uses a Relative Move method to move
191, the cloud 50 twips closer to the left
193, edge of the form and 75 twips closer to
196, the top edge of the form. As you'll see
199, when you run the program, this movement
201, gives the cloud animation a gentle, drift
204, quality. When the cloud reaches the top
207, of the form, the Else clause in the
210, Timer1_Timer procedure makes the picture
213, invisible and disables the timer, which
217, ends the animation. Now I'll run the
221, program. Well, we've run the burn barrel
230, program before, so I'll demonstrate quickly
232, how the icons are dropped in. The gas
234, will really get this thing stoking and the
237, CD makes some good burning material.
239, When we put in the match, the cloud
242, animation begins and floats gently off the
245, screen. Pretty cool, huh? Well, if you like
248, this effect, take a few moments to
249, create your own animations with the
251, Picture Box and Timer controls. I think your
253, users will appreciate the results.
257, END